using DAL=IrisGenerator.Common.DatabaseModel.DataAccess;
using IrisGenerator.Common.Tools;
namespace IrisGenerator.Common.DatabaseModel {
    
    
    public partial class InsertColumns {
        
        private System.Nullable<System.Guid> _reqId;
        
        private System.Nullable<System.Guid> _colId;
        
        private Column _column;
        
        private Request _request;
        
        public virtual System.Nullable<System.Guid> ReqId {
            get {
                return _reqId;
            }
            set {
                _reqId = value;
            }
        }
        
        public virtual System.Nullable<System.Guid> ColId {
            get {
                return _colId;
            }
            set {
                _colId = value;
            }
        }
        
        public virtual Column Column {
            get {
                if ((this._column == null)) {
                    this._column = IrisGenerator.Common.DatabaseModel.Column.Load(this._colId);
                }
                return this._column;
            }
            set {
                _column = value;
            }
        }
        
        public virtual Request Request {
            get {
                if ((this._request == null)) {
                    this._request = IrisGenerator.Common.DatabaseModel.Request.Load(this._reqId);
                }
                return this._request;
            }
            set {
                _request = value;
            }
        }
        
        private void Clean() {
            this.ReqId = null;
            this.ColId = null;
            this.Column = null;
            this.Request = null;
        }
        
        private void Fill(System.Data.DataRow dr) {
            this.Clean();
            if ((dr["REQ_ID"] != System.DBNull.Value)) {
                this.ReqId = ((System.Nullable<System.Guid>)(dr["REQ_ID"]));
            }
            if ((dr["COL_ID"] != System.DBNull.Value)) {
                this.ColId = ((System.Nullable<System.Guid>)(dr["COL_ID"]));
            }
        }
        
        public static InsertColumnsCollection Select_INSERT_COLUMNS_By_COL_ID(System.Nullable<System.Guid> COL_ID) {
            DAL.InsertColumns dbo = null;
            try {
                dbo = new DAL.InsertColumns();
                System.Data.DataSet ds = dbo.Select_INSERT_COLUMNS_By_COL_ID(COL_ID);
                InsertColumnsCollection collection = new InsertColumnsCollection();
                if (GlobalTools.IsSafeDataSet(ds)) {
                    for (int i = 0; (i < ds.Tables[0].Rows.Count); i = (i + 1)) {
                        InsertColumns obj = new InsertColumns();
                        obj.Fill(ds.Tables[0].Rows[i]);
                        if ((obj != null)) {
                            collection.Add(obj);
                        }
                    }
                }
                return collection;
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
        
        public static InsertColumnsCollection Select_INSERT_COLUMNS_By_REQ_ID(System.Nullable<System.Guid> REQ_ID) {
            DAL.InsertColumns dbo = null;
            try {
                dbo = new DAL.InsertColumns();
                System.Data.DataSet ds = dbo.Select_INSERT_COLUMNS_By_REQ_ID(REQ_ID);
                InsertColumnsCollection collection = new InsertColumnsCollection();
                if (GlobalTools.IsSafeDataSet(ds)) {
                    for (int i = 0; (i < ds.Tables[0].Rows.Count); i = (i + 1)) {
                        InsertColumns obj = new InsertColumns();
                        obj.Fill(ds.Tables[0].Rows[i]);
                        if ((obj != null)) {
                            collection.Add(obj);
                        }
                    }
                }
                return collection;
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
        
        public static InsertColumnsCollection GetAll() {
            DAL.InsertColumns dbo = null;
            try {
                dbo = new DAL.InsertColumns();
                System.Data.DataSet ds = dbo.INSERT_COLUMNS_Select_All();
                InsertColumnsCollection collection = new InsertColumnsCollection();
                if (GlobalTools.IsSafeDataSet(ds)) {
                    for (int i = 0; (i < ds.Tables[0].Rows.Count); i = (i + 1)) {
                        InsertColumns obj = new InsertColumns();
                        obj.Fill(ds.Tables[0].Rows[i]);
                        if ((obj != null)) {
                            collection.Add(obj);
                        }
                    }
                }
                return collection;
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
        
        public static InsertColumns Load(System.Nullable<System.Guid> REQ_ID, System.Nullable<System.Guid> COL_ID) {
            DAL.InsertColumns dbo = null;
            try {
                dbo = new DAL.InsertColumns();
                System.Data.DataSet ds = dbo.INSERT_COLUMNS_Select_One(REQ_ID, COL_ID);
                InsertColumns obj = null;
                if (GlobalTools.IsSafeDataSet(ds)) {
                    if ((ds.Tables[0].Rows.Count > 0)) {
                        obj = new InsertColumns();
                        obj.Fill(ds.Tables[0].Rows[0]);
                    }
                }
                return obj;
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
        
        public virtual void Load() {
            DAL.InsertColumns dbo = null;
            try {
                dbo = new DAL.InsertColumns();
                System.Data.DataSet ds = dbo.INSERT_COLUMNS_Select_One(this.ReqId, this.ColId);
                if (GlobalTools.IsSafeDataSet(ds)) {
                    if ((ds.Tables[0].Rows.Count > 0)) {
                        this.Fill(ds.Tables[0].Rows[0]);
                    }
                }
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
        
        public virtual void Insert() {
            DAL.InsertColumns dbo = null;
            try {
                dbo = new DAL.InsertColumns();
                dbo.INSERT_COLUMNS_Insert(this.Request.ReqId, this.Column.ColId);
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
        
        public virtual void Delete() {
            DAL.InsertColumns dbo = null;
            try {
                dbo = new DAL.InsertColumns();
                dbo.INSERT_COLUMNS_Delete(this.ReqId, this.ColId);
            }
            catch (System.Exception ) {
                throw;
            }
            finally {
                if ((dbo != null)) {
                    dbo.Dispose();
                }
            }
        }
    }
}
